/**
 * 试剂瓶
 */
Bottle3 = Widget.extend({
	runningAction:null,
	ctor:function(parent){
		this._super();
		parent.addChild(this,31,TAG_BOTTLE3_ALL);
		this.init();
		this.initAction();
	},
	init : function(){
		var bottle3=new Button(this,10,TAG_BOTTLE3,"#bottle2.png",this.callback,this);
		bottle3.setPosition(cc.p(1000, 280));
		
		var title3=new Button(bottle3,9,TAG_TITLE3,"#title3.png",this.callback,this);
		title3.setPosition(cc.p(bottle3.width*0.5, bottle3.height*0.45));
		
		var lid=new Button(this,9,TAG_LID3,"#lid1.png",this.callback,this);
		lid.setPosition(cc.p(1000, 370));
	},
	initAction:function(){
		var animFrames=[];
		for(var i=1;i<5;i++){
			var str="action1/action"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.25);
		this.runningAction=cc.repeat(cc.animate(animation),1);
		this.runningAction.retain();
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		}, this);
		switch(p.getTag()){
		case TAG_BOTTLE3:
			var ber=cc.bezierBy(1, [cc.p(-50, 100),cc.p(-125, 168),cc.p(-550,370)]);
			var rotate=cc.rotateBy(1,-85);
			var lid=this.getChildByTag(TAG_LID3);
			p.runAction(cc.sequence(cc.spawn(cc.callFunc(function() {
				ll.run.rack.takeTube2();
			},this),ber,rotate,
				this.runningAction
			),cc.callFunc(function() {
				ll.run.rack.upLine2();
			},this),cc.delayTime(1),cc.callFunc(function() {
				ll.run.rack.putTube2();
			}, this),cc.callFunc(function(){
				lid.removeFromParent(true);
				p.removeFromParent(true);
			},this),func));
			break;
		case TAG_LID3:
			var ber=cc.bezierBy(1, [cc.p(30,50),cc.p(65, 80),cc.p(88, -180)]);
			var rotate=cc.rotateBy(1,180);
			p.runAction(cc.sequence(cc.spawn(ber,rotate),func));
			break;
			break;
		}
	}
});
